package com.web.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.web.util.WebContextUtil;

//处理跨域问题
@CrossOrigin(origins = "*", maxAge = 3600)
@RestController
public class TestController {

	//produces 响应的类型和编码，解决响应的中文乱码
	@RequestMapping(value="/test", produces="text/html;charset=UTF-8")
	public String test() {
		HttpServletRequest request = WebContextUtil.getRequest();
//		String webPath = request.getSession().getServletContext().getRealPath("/");
		String webPath = request.getSession().getServletContext().getRealPath("/pic/");
		System.out.println(webPath);
		return "TestController";
	}
}
